package com.ivo.web.form.def;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import com.ivo.util.StringUtil;
import com.ivo.web.form.intf.Field;

public class FieldImpl extends ComponentImpl implements Field
{
	protected String width;
	protected String height;
	protected String value;

	public String getWidth()
	{
		return width;
	}

	public void setWidth(String width)
	{
		this.width = width;
	}

	public String getHeight()
	{
		return height;
	}

	public void setHeight(String height)
	{
		this.height = height;
	}

	public String getValue()
	{
		return value;
	}

	public void setValue(String value)
	{
		this.value = value;
	}

	@Override
	public String toHtml()
	{
		Document document = DocumentHelper.createDocument();
		Element div = document.addElement( "input" );
		div.addAttribute( "type", "text" );
		if( StringUtil.notEmpty( id ) ) div.addAttribute( "id", id );
		if( StringUtil.notEmpty( name ) ) div.addAttribute( "name", name );
		if( StringUtil.notEmpty( style ) ) div.addAttribute( "style", style );
		if( StringUtil.notEmpty( css ) ) div.addAttribute( "css", css );
		if( StringUtil.notEmpty( width ) ) div.addAttribute( "width", width );
		if( StringUtil.notEmpty( height ) ) div.addAttribute( "height", height );
		if( StringUtil.notEmpty( value ) ) div.addAttribute( "value", value );
		//-------------------------------------------------------------------
		return div.asXML();
	}

}
